﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk;

namespace XrmLibrary.MsCrm4Adapter.Extensions
{
    public static class DynamicEntityExtensions
    {
        public static Entity ToEntity(this DynamicEntity dynamicEntity)
        {
            Entity entity = new Entity(dynamicEntity.Name);
            foreach(Property crm4Property in dynamicEntity.Properties)
            {
                KeyValuePair<String, Object> crm2011Attribute = crm4Property.ToCrm2011Attribute();
                entity.Attributes.Add(crm2011Attribute);
            }
            return entity;
        }
    }
}
